<?php $actions = $this->actions ?>
<?php foreach ($actions as $action): ?>
    <div class='action'>
        <div class='post-title'>
            <a href='<?php echo FACEBOOK_URL . "/{$action->id_social_user}" ?>' name='fan-name' class='fb-name' target='_blank'>
            </a>
            <?php
            switch ($action->type) {
                case POST:
                    echo $this->translate->_("POSTED");
                    break;
                case COMMENT:
                    echo $this->translate->_("COMMENTED") . ' ';
                    echo '<i>' . $action->action_message . '</i>';
                    break;
                case LIKE:
                    echo $this->translate->_("LIKED");
                    break;
                case VOTE:
                    echo $this->translate->_("VOTED");
                    break;
            }
            ?>
        </div>
        <div class='wrap-post'>
            <div class='post-avatar post-div'>
                <img src='<?php echo $this->facebook->getAvatar($action->target_id_social_from, 100, 100) ?>' width='75px' height='75px'/>
            </div>
            <div class='post-content post-div'>
                <a href='<?php echo FACEBOOK_URL . "/{$action->target_id_social_from}"?>' class='fb-name' id='<?php echo $action->target_id_social_from ?>' target='_blank'>
                </a>
                <i><?php echo $action->target_message ?></i>
                <?php if (!empty($action->picture)): ?>
                    <div class='post-picture'>
                        <img src='<?php echo $action->picture ?>'/>
                    </div>
                <?php endif; ?>
                <?php if ($action->type != VOTE): ?>
                    <div class='wrap-post-action'>
                        <div class='report-icon post-icon'>
                            <?php echo date('m/d/Y', $action->target_created_time) ?>
                        </div>
                    </div>
                <?php endif; ?>
            </div>                   
        </div>
        <div class='sub-info'>
            <?php if (isset($action->created_time)): ?>
                <?php echo date('d/m/Y', $action->created_time) ?>
            <?php endif; ?>
        </div> 
    </div>
<?php endforeach; ?>

<?php if (sizeof($actions) >= ACTION_PER_PAGE): ?>
    <a href='javascript:void(0)' onclick='viewMoreAction()'>
        <div class='blue-box'>
            <span>
                View More
                <span class='icon down-arrow'></span>
            </span>
        </div>
    </a>    
<?php endif; ?>

<script>
    FB.api("/" + id_social_user + "?fields=name", function(data){
       var name = data.name;
       $("[name='fan-name']").each(function(){
           $(this).html(name);
       });
    });    
    
    $(".fb-name").each(function(){
        var id_social = $(this).attr("id");
        FB.api("/" + id_social + "?fields=name", function(data) {
            var id_social = data.id;
            $(".fb-name[id='" + id_social + "']").html(data.name);
        });
    });
</script>
